#include <stdio.h>

/*回文数的形成*/

#define MAX 2147483647
long re(long int a);
int nonre(long int s);


void main()
{
    long int n,m,re();
    int count=0;
    printf("please enter annumber optionaly:");
    scanf("%ld",&n);
    printf("The generation process of palindrome:\n");
    while(!nonre((m=re(n))+n))
    {
        if(m+n>=MAX)
        {
            printf("input error,break.\n");
            break;
        }
        else {
            printf("[%d]:%ld+%ld=%ld\n",++count,n,m,m+n);
            n+=m;
        }
    }
    printf("Here we reched the aim at last!\n");

}

long re(long int a)
{
    long int t;
    for(t=0;a>0;a/=10)
    t=t*10+a%10;
    return(t);
}

int nonre(long int s)
{
    if(re(s)==s)  return 1;
    else return 0;
}
